<template>
  <div>
    <data-view />
  </div>
</template>

<script lang="ts">
import {Vue, Component} from "vue-property-decorator";
import BaseApi from "@/api/BaseApi";
import XRouterConfig from "@/api/XRouterConfig";
import BottomTabView from "@/pages/components/bottom_tab_view.vue";
import UnitView from "@/pages/unit/unit_view.vue";
import UserView from "@/pages/user/user_view.vue";
import DataView from "@/pages/data/data_view.vue";
import ApiDefine from "@/api/ApiDefine";

@Component({
  components: {
    DataView,
    BottomTabView,
    UnitView,
    UserView,
  },
})
export default class Home extends Vue {

  tabList = [
    {title: "数据汇报", normalImg: '/static/data.png', selectImg: '/static/data_on.png'},
    {title: "楼栋使用", normalImg: '/static/house.png', selectImg: '/static/house_on.png'}
  ];
  active: number = 0;

  onChange(event: any) {
    this.active = event;
  }

  created() {
	  console.log(BaseApi.instance().sysuserid,'BaseApi.instance().sysuserid')
    this.initUserInfo();
  }
  //上拉加载数据
  onReachBottom() {
	  console.log('crj')
    uni.$emit("onReachBottom", this.active)
  }

  async initUserInfo() {
    let value = await BaseApi.instance().fetch(ApiDefine.USE_INFO_URL,
        {sysuserid: uni.getStorageSync('userId')});
    if (value == null || value.code != 200) {
      return;
    }
    BaseApi.instance().saveUserInfo(value.data ?? {});
  }
}
</script>

<style scoped>
</style>
